
package com.j2eefast.produce.pms.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.framework.sys.entity.SysUserEntity;
import com.j2eefast.framework.utils.Constant;
import com.j2eefast.framework.utils.UserUtils;
import com.j2eefast.produce.pms.entity.PmsProjectEntity;
import com.j2eefast.produce.pms.entity.PmsSampleEntryEntity;
import com.j2eefast.produce.pms.mapper.PmsProjectMapper;
import com.j2eefast.produce.pms.mapper.PmsSampleEntryMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>工程项目</p>
 *
 * @author: summer
 * @date: 2021-05-29 16:47
 * @web: http://www.letukeji.cn
 * @version: 1.0.1
 */
@Service
@Transactional(readOnly = true)
public class PmsProjectService extends ServiceImpl<PmsProjectMapper, PmsProjectEntity> {

	@Resource
	protected PmsProjectMapper pmsProjectMapper;


	/**
	 * 页面展示查询翻页
	 */
	public PageUtil findPage(Map<String, Object> params) {
//		String sampleCode = (String) params.get("sampleCode");
//		String sampleType = (String) params.get("sampleType");


		Page<PmsProjectEntity> page = pmsProjectMapper.findPage(
				new Query<PmsProjectEntity>(params).getPage(),
//				StrUtil.nullToDefault(sampleCode,""),
//				StrUtil.nullToDefault(sampleType,""),
				(String) params.get(Constant.SQL_FILTER));
		return new PageUtil(page);
	}

	@Transactional(rollbackFor = Exception.class)
	public boolean deleteByIds(Long[] ids) {

		return pmsProjectMapper.deleteByIds(ids);

	}
	@Transactional(rollbackFor = Exception.class)
	public boolean updateCheck(Long id) {
		Long userId= UserUtils.getUserInfo().getId();

		return pmsProjectMapper.updateCheck(id ,userId);

	}
	public SysUserEntity getSysById(@Param("userId")Long userId){
		return pmsProjectMapper.getSysById(userId);
	}



}
